package com.yun.zf.system.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yun.zf.common.app.domain.ZfCity;
import com.yun.zf.common.app.dto.home.OpenCityDto;
import com.yun.zf.common.utils.TreeNodes;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 * 城市区域表 Mapper 接口
 * </p>
 *
 * @author cj
 * @since 2021-01-29
 */
@Mapper
public interface ZfCityMapper extends BaseMapper<ZfCity> {

    @Update("<script>" +
            " UPDATE zf_city set abbreviation=#{str} ,first_pinyin=#{firtpy} WHERE id=#{id} " +
            "</script>")
    public void updateAbbreviation(String str ,int id,String firtpy);

    @Select("<script>" +
            "SELECT c.city_code id ,city_name name, pid parentId ,first_pinyin firstPinyin  from zf_city c WHERE c.sec_level=#{cityCode}" +
            "</script>")
    public List<TreeNodes> getSearchCity(Long cityCode);

    @Select("<script>" +
            "SELECT c.city_code,city_name,c.pid,c.first_pinyin ,one_level_name  FROM zf_city c WHERE  c.`level`='C' AND c.is_open=0 " +
            "</script>")
    public List<OpenCityDto> getOpenCity();

    @Select("<script>" +
            "SELECT c.city_code,city_name,c.pid,c.first_pinyin FROM zf_city c WHERE  c.`level`='C' AND c.is_hot=0 " +
            "</script>")
    public List<OpenCityDto> getHotCity();


    @Select("<script>" +
            "SELECT c.city_code,city_name,c.pid,c.first_pinyin,one_level_name  FROM zf_city c WHERE   c.is_open=0  " +
            "</script>")
    public List<OpenCityDto> getManagerCity();
}
